package net.dgg.rz.common.checkRecord.controller;


import net.dgg.framework.tac.utils.bean.DggRestResponse;
import net.dgg.framework.tac.utils.web.commmon.DggBaseController;
import net.dgg.rz.common.checkRecord.entity.CheckRecord;
import net.dgg.rz.common.checkRecord.service.CheckRecordService;
import net.dgg.rz.common.constant.ScProductConstant;
import net.dgg.rz.common.excption.CommonExcption;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 操作日志
 *
 * @Author:CP
 * @Date: Created in 2019/2/26 14:09
 * @Copyright © dgg group.All Rights Reserved. 版权信息
 */
@Controller
@RequestMapping("check_record/")
public class CheckRecordController extends DggBaseController {

    @Autowired
    private CheckRecordService checkRecordService;
    /**
     * 保存放大镜查看记录
     */
    @RequestMapping("/save_check_record")
    @ResponseBody
    public DggRestResponse saveCheckRecord(String contactId,String scproductId,String operaterType,String remarks,String tableName){
        try {
            CheckRecord checkRecord = new CheckRecord();
            checkRecord.setContactId(Long.parseLong(contactId));
            checkRecord.setScproductId(Long.parseLong(scproductId));
            checkRecord.setOperaterType(operaterType);
            checkRecord.setRemarks(remarks);
            checkRecord.setOperaterTableName(tableName);
            checkRecordService.saveCheckRecord(checkRecord);
            return this.getSuccessResponse("保存成功");
        }catch (CommonExcption e){
            e.printStackTrace();
            return this.getFailResponse(e.getMessage());
        }catch (Exception e) {
            e.printStackTrace();
            return this.getFailResponse(ScProductConstant.SYS_ERROR);
        }
    }

}
